#include "ConfigKey.h"

using namespace std;

ConfigKey::ConfigKey( std::string name, std::string value ) {
    m_name = name;
    m_value = value;
}

ConfigKey::~ConfigKey( void ) {}

std::string ConfigKey::getName( void )
{
    return m_name;
}

string ConfigKey::getStringValue( void )
{
    return m_value;
}

int ConfigKey::getIntValue( void )
{
    std::istringstream iss( m_value );
    int integer;
    iss >> integer;
    return integer;
}

float ConfigKey::getFloatValue( void )
{
    std::istringstream iss( m_value );
    float real;
    iss >> real;
    return real;
}

bool ConfigKey::getBoolValue( void )
{
    if( m_value == "y" || m_value == "yes" || m_value == "oui" || m_value == "1" || m_value == "true" )
    {
        return true;
    }
    if( m_value == "n" || m_value == "no" || m_value == "non" || m_value == "0" || m_value == "false" )
    {
        return false;
    }

    throw NumberFormatException("Can't convert '" + m_value + "' to bool type");
}
